package com.hzit.mapper;

import com.hzit.entity.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
public interface StudentMapper {

	//1. 查询所有学生
	@Select("select * from student")
	List<Student> findAll();

	//2. 添加学生
	@Insert("insert into student values(null,#{sname},#{sex},#{age},#{addr},#{cid},#{birth})")
	void insert(Student stud);

	//3. 根据sid查询学生
	@Select("select * from student where sid = #{sid}")
	Student findById(Integer sid);

	//4. 修改学生
	@Update("update student set sname=#{sname},sex=#{sex},age=#{age},addr=#{addr},cid=#{cid},birth=#{birth} where sid=#{sid}")
	void update(Student stud);

	//5. 根据学号删除学生
	@Delete("delete from student where sid=#{sid}")
	void delete(Integer sid);
}
